{extend name='table'}

{block name="search"}
    <div class="layui-form layui-form-pane form-search">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">会员</label>
            <div class="layui-input-inline">
                <input name="keyword" value="{$get.keyword|default=''}" placeholder="姓名/手机号" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-inline">
                <select name="type">
                    <option value="">- 全部 -</option>
                    <option value="1" {if input('get.type')=='1'}selected{/if}>获得</option>
                    <option value="2" {if input('get.type')=='2'}selected{/if}>消费</option>
                    <option value="3" {if input('get.type')=='3'}selected{/if}>调整</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">来源</label>
            <div class="layui-input-inline">
                <select name="source">
                    <option value="">- 全部 -</option>
                    <option value="checkin" {if input('get.source')=='checkin'}selected{/if}>打卡</option>
                    <option value="exchange" {if input('get.source')=='exchange'}selected{/if}>兑换</option>
                    <option value="adjust" {if input('get.source')=='adjust'}selected{/if}>调整</option>
                </select>
            </div>
        </div>
        {if $isMaster}
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">门店</label>
            <div class="layui-input-inline">
                <select name="store_id">
                    <option value="">- 全部 -</option>
                    {foreach $stores as $s}
                    <option value="{$s.id}" {if input('get.store_id') == $s.id}selected{/if}>{$s.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="status">
                    <option value="">- 全部 -</option>
                    <option value="1" {if input('get.status')=='1'}selected{/if}>有效</option>
                    <option value="0" {if input('get.status')=='0'}selected{/if}>无效/过期</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
                <input data-date-range name="create_time" value="{$get.create_time|default=''}" placeholder="- 选择时间范围 -" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <button class="layui-btn" data-table-search><i class="layui-icon layui-icon-search"></i> 搜 索</button>
            <button class="layui-btn layui-btn-primary" data-table-reset><i class="layui-icon layui-icon-refresh-1"></i> 重 置</button>
        </div>
    </div>
{/block}

{block name="content"}
    <table id="PointsTable" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
{/block}

{block name="script"}
<script>
layui.use(['jquery'], function () {
  var $ = layui.$;
  let typeMap = {1:'获得',2:'消费',3:'调整'};
  let sourceMap = {checkin:'打卡',exchange:'兑换',adjust:'调整'};
  let cols = [[
    {type:'checkbox'},
    {field:'id', title:'ID', width:70, sort:true},
    {field:'member_name', title:'会员姓名', width:120},
    {field:'member_phone', title:'手机号', width:120},
    {field:'type', title:'类型', width:90, templet: d=> typeMap[d.type]||d.type},
    {field:'source', title:'来源', width:90, templet: d=> sourceMap[d.source]||d.source},
    {field:'points', title:'积分', width:90, sort:true},
    {field:'store_name', title:'门店', width:140},
    {field:'operator_name', title:'操作员', width:120},
    {field:'expire_time', title:'过期时间', width:170},
    {field:'status', title:'状态', width:100, templet: d=> d.status==1?'<span class="color-green">有效</span>':'<span class="color-red">无效/过期</span>'},
    {field:'remark', title:'备注', minWidth:180},
    {field:'create_time', title:'创建时间', width:170, sort:true}
  ]];
  $('#PointsTable').layTable({ even:true, height:'full-200', cols: cols });
});
</script>
{/block}
